package com.aaa.system.controller.api;

import com.aaa.entity.OperLog;
import com.aaa.system.aop.annotation.Log;
import com.aaa.system.service.IOperLogService;
import com.aaa.system.vo.OperLogVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 响应到前端的controller类
 */
@RestController
@RequestMapping("system/api/operlog")
public class ApiOperLogController {

    @Autowired
    private IOperLogService operLogService;

    /**
     * 分页动态查询所有操作日志
     * @param current  当前页码
     * @param size  每页显示条数
     * @param operLogVo 操作日志查询条件对象
     * @return  操作结果信息
     */
    @PostMapping("selectAll/{current}/{size}")
    public Result<IPage<OperLog>> selectAll(
            @PathVariable Integer current,
            @PathVariable Integer size,
            @RequestBody OperLogVo operLogVo
    ){
        Result<IPage<OperLog>> selectAll = operLogService.selectAll(current,size,operLogVo);
        return selectAll;
    }

    /**
     * 根据操作日志id删除单个或者多个操作日志
     * @param operIds 操作日志id数组
     * @return 操作结果信息
     */
    @DeleteMapping("deleteOperLogByIds/{operIds}")
    @Log(title = "删除单条或者多条操作日志",business_type = "3")
    public Result<Boolean> deleteOperLogByIds(@PathVariable long[] operIds){
        return operLogService.deleteOperLogByIds(operIds);
    }

    /**
     * 删除所有的操作日志信息
     * @return 操作结果信息
     */
    @DeleteMapping("truncateTable")
    public Result<Boolean> truncateTable(){
        return operLogService.truncateTable();
    }
}
